// string basic operation

#include <stdio.h>
#include <string.h>

int main(int argc, char const *argv[])
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        char s[12], *suffix;
        int cutoff, len = strlen(s);
        scanf("%s", s);
        if (s[len - 1] == 'x' || s[len - 1] == 's' || s[len - 1] == 'o' || (len > 1 && s[len - 2] == 'c' && s[len - 1] == 'h'))
        {
            cutoff = 0;
            suffix = "es";
        }
        else if (len > 1 && s[len - 2] == 'f' && s[len - 1] == 'e')
        {
            cutoff = 2;
            suffix = "ves";
        }
        else if (s[len - 1] == 'f')
        {
            cutoff = 1;
            suffix = "ves";
        }
        else if (s[len - 1] == 'y')
        {
            cutoff = 1;
            suffix = "ies";
        }
        else
        {
            cutoff = 0;
            suffix = "s";
        }
        s[len - cutoff] = '\0';
        printf("%s\n", strcat(s, suffix));
    }
    return 0;
}
